home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / xceedzip / xceedzip.exe / Samples / Zip Manager / Vb6 / frmZip.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-04-27  |  17.6 KB  |  427 lines

  1. VERSION 5.00
  2. Begin VB.Form frmZip 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Add file(s) to the zip file"
  5.    ClientHeight    =   5325
  6.    ClientLeft      =   1065
  7.    ClientTop       =   1200
  8.    ClientWidth     =   6525
  9.    Icon            =   "frmZip.frx":0000
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   5325
  13.    ScaleWidth      =   6525
  14.    StartUpPosition =   1  'CenterOwner
  15.    Begin VB.CommandButton cmdFilters 
  16.       Caption         =   "&Filters..."
  17.       Height          =   375
  18.       Left            =   5160
  19.       TabIndex        =   12
  20.       Top             =   600
  21.       Width           =   1215
  22.    End
  23.    Begin VB.TextBox txtFilesToProcess 
  24.       Height          =   1050
  25.       Left            =   120
  26.       MultiLine       =   -1  'True
  27.       ScrollBars      =   2  'Vertical
  28.       TabIndex        =   0
  29.       ToolTipText     =   "For multiple choices, seperate each filter with a line feed."
  30.       Top             =   360
  31.       Width           =   4815
  32.    End
  33.    Begin VB.CommandButton cmdFilesToProcess 
  34.       Caption         =   "&Browse"
  35.       Height          =   285
  36.       Left            =   4215
  37.       TabIndex        =   1
  38.       Top             =   1470
  39.       Width           =   735
  40.    End
  41.    Begin VB.CommandButton cmdSfx 
  42.       Caption         =   "&SFX..."
  43.       Height          =   375
  44.       Left            =   5160
  45.       TabIndex        =   14
  46.       Top             =   1495
  47.       Width           =   1215
  48.    End
  49.    Begin VB.Frame fraSplit 
  50.       Caption         =   "Splitting"
  51.       BeginProperty Font 
  52.          Name            =   "MS Sans Serif"
  53.          Size            =   8.25
  54.          Charset         =   0
  55.          Weight          =   700
  56.          Underline       =   0   'False
  57.          Italic          =   0   'False
  58.          Strikethrough   =   0   'False
  59.       EndProperty
  60.       Height          =   975
  61.       Left            =   120
  62.       TabIndex        =   19
  63.       Top             =   3780
  64.       Width           =   4815
  65.       Begin VB.CheckBox chkSplitting 
  66.          Caption         =   "C&reate a zip file that is split into smaller pieces"
  67.          Height          =   255
  68.          Left            =   120
  69.          TabIndex        =   8
  70.          Top             =   240
  71.          Width           =   3735
  72.       End
  73.       Begin VB.TextBox txtSplitSize 
  74.          Enabled         =   0   'False
  75.          Height          =   285
  76.          Left            =   3120
  77.          TabIndex        =   9
  78.          Top             =   570
  79.          Width           =   615
  80.       End
  81.       Begin VB.Label lblK 
  82.          Caption         =   "kbytes."
  83.          Enabled         =   0   'False
  84.          Height          =   255
  85.          Left            =   3840
  86.          TabIndex        =   21
  87.          Top             =   600
  88.          Width           =   495
  89.       End
  90.       Begin VB.Label lblSplitSize 
  91.          Caption         =   "I want the zip file to be split into pieces of"
  92.          Enabled         =   0   'False
  93.          Height          =   255
  94.          Left            =   120
  95.          TabIndex        =   20
  96.          Top             =   600
  97.          Width           =   3015
  98.       End
  99.    End
  100.    Begin VB.Frame fraSkipping 
  101.       Caption         =   "Do not zip files that..."
  102.       BeginProperty Font 
  103.          Name            =   "MS Sans Serif"
  104.          Size            =   8.25
  105.          Charset         =   0
  106.          Weight          =   700
  107.          Underline       =   0   'False
  108.          Italic          =   0   'False
  109.          Strikethrough   =   0   'False
  110.       EndProperty
  111.       Height          =   1260
  112.       Left            =   120
  113.       TabIndex        =   18
  114.       Top             =   2430
  115.       Width           =   4815
  116.       Begin VB.CheckBox chkSkipIfOlderVersion 
  117.          Caption         =   "Are older &versions than files already in the zip file"
  118.          Height          =   195
  119.          Left            =   120
  120.          TabIndex        =   7
  121.          Top             =   960
  122.          Width           =   3855
  123.       End
  124.       Begin VB.CheckBox chkSkipIfOlderDate 
  125.          Caption         =   "Are ol&der than files already in the zip file"
  126.          Height          =   195
  127.          Left            =   120
  128.          TabIndex        =   6
  129.          Top             =   720
  130.          Width           =   3855
  131.       End
  132.       Begin VB.CheckBox chkSkipIfNotExisting 
  133.          Caption         =   "Are ¬ already in the zip file"
  134.          Height          =   195
  135.          Left            =   120
  136.          TabIndex        =   5
  137.          Top             =   480
  138.          Width           =   2775
  139.       End
  140.       Begin VB.CheckBox chkSkipIfExisting 
  141.          Caption         =   "Are &already in the zip file"
  142.          Height          =   195
  143.          Left            =   120
  144.          TabIndex        =   4
  145.          Top             =   240
  146.          Width           =   2655
  147.       End
  148.    End
  149.    Begin VB.CommandButton cmdPasswordProtect 
  150.       Caption         =   "&Password..."
  151.       Height          =   375
  152.       Left            =   5160
  153.       TabIndex        =   13
  154.       Top             =   1045
  155.       Width           =   1215
  156.    End
  157.    Begin VB.ComboBox cmbCompLevel 
  158.       Height          =   315
  159.       Left            =   1630
  160.       Style           =   2  'Dropdown List
  161.       TabIndex        =   10
  162.       Top             =   4870
  163.       Width           =   1935
  164.    End
  165.    Begin VB.Frame fraFolders 
  166.       Caption         =   "Folders and paths"
  167.       BeginProperty Font 
  168.          Name            =   "MS Sans Serif"
  169.          Size            =   8.25
  170.          Charset         =   0
  171.          Weight          =   700
  172.          Underline       =   0   'False
  173.          Italic          =   0   'False
  174.          Strikethrough   =   0   'False
  175.       EndProperty
  176.       Height          =   780
  177.       Left            =   120
  178.       TabIndex        =   16
  179.       Top             =   1560
  180.       Width           =   2175
  181.       Begin VB.CheckBox chkProcessSubFolders 
  182.          Caption         =   "&Include subfolders"
  183.          Height          =   195
  184.          Left            =   120
  185.          TabIndex        =   2
  186.          Top             =   240
  187.          Value           =   1  'Checked
  188.          Width           =   1815
  189.       End
  190.       Begin VB.CheckBox chkPreservePaths 
  191.          Caption         =   "S&tore paths in zip file"
  192.          Height          =   195
  193.          Left            =   120
  194.          TabIndex        =   3
  195.          Top             =   480
  196.          Value           =   1  'Checked
  197.          Width           =   1935
  198.       End
  199.    End
  200.    Begin VB.CommandButton cmdCancel 
  201.       Cancel          =   -1  'True
  202.       Caption         =   "&Cancel"
  203.       Height          =   375
  204.       Left            =   5160
  205.       TabIndex        =   15
  206.       Top             =   1950
  207.       Width           =   1215
  208.    End
  209.    Begin VB.CommandButton cmdZip 
  210.       Caption         =   "&Zip!"
  211.       Height          =   375
  212.       Left            =   5160
  213.       TabIndex        =   11
  214.       Top             =   150
  215.       Width           =   1215
  216.    End
  217.    Begin VB.Label lblFilesToProcess 
  218.       Caption         =   "Enter the list of files to add or update in the zip file:"
  219.       Height          =   255
  220.       Left            =   120
  221.       TabIndex        =   22
  222.       Top             =   120
  223.       Width           =   4335
  224.    End
  225.    Begin VB.Label lblCompLevel 
  226.       Caption         =   "Compression factor:"
  227.       Height          =   255
  228.       Left            =   120
  229.       TabIndex        =   17
  230.       Top             =   4915
  231.       Width           =   1575
  232.    End
  233. Attribute VB_Name = "frmZip"
  234. Attribute VB_GlobalNameSpace = False
  235. Attribute VB_Creatable = False
  236. Attribute VB_PredeclaredId = True
  237. Attribute VB_Exposed = False
  238. Option Explicit
  239. '==================================================================
  240. ' Description: The frmZip form is displayed whenever it is time for
  241. '              the user to select files to add or update in the zip
  242. '              file.
  243. '==================================================================
  244. ' We keep a link on the XceedZip instance that we receive in the
  245. ' ShowForm method, so we don't depend on the main form's instance
  246. Dim xCurrentZip As XceedZip
  247. '------------------------------------------------------------------------------------
  248. 'This sub calls data loading functions so that all of the form's
  249. 'controls are initialized with the correct values
  250. '------------------------------------------------------------------------------------
  251. Private Sub LoadProperties(xZip As XceedZip)
  252.     Call LoadComboBox(xZip)
  253.     Call LoadFolderProperties(xZip)
  254.     Call LoadSkippingProperties(xZip)
  255.     Call LoadSplitFileProperties(xZip)
  256.     cmbCompLevel.ItemData(cmbCompLevel.ListIndex) = xZip.CompressionLevel
  257. End Sub
  258. '------------------------------------------------------------------------------------
  259. 'Fill the Compression Level combo box with the appropriate choices
  260. '------------------------------------------------------------------------------------
  261. Private Sub LoadComboBox(xZip As XceedZip)
  262.     cmbCompLevel.AddItem ("Maximum")
  263.     cmbCompLevel.ItemData(0) = xclHigh
  264.     cmbCompLevel.AddItem ("Normal")
  265.     cmbCompLevel.ItemData(1) = xclMedium
  266.     cmbCompLevel.AddItem ("Low")
  267.     cmbCompLevel.ItemData(2) = xclLow
  268.     cmbCompLevel.AddItem ("No Compression")
  269.     cmbCompLevel.ItemData(3) = xclNone
  270.     cmbCompLevel.ListIndex = (1)
  271. End Sub
  272. '------------------------------------------------------------------------------------
  273. 'Sets the form's "files and paths" checkboxes from the xZip object's
  274. 'PreservePaths and ProcessSubfolders properties.
  275. '------------------------------------------------------------------------------------
  276. Private Sub LoadFolderProperties(xZip As XceedZip)
  277.     chkPreservePaths.Value = IIf(xZip.PreservePaths, vbChecked, vbUnchecked)
  278.     chkProcessSubFolders.Value = IIf(xZip.ProcessSubfolders, vbChecked, vbUnchecked)
  279. End Sub
  280. '------------------------------------------------------------------------------------
  281. 'Sets the form's "Skipping" options from the xZip object's properties
  282. '------------------------------------------------------------------------------------
  283. Private Sub LoadSkippingProperties(xZip As XceedZip)
  284.     chkSkipIfExisting.Value = xZip.SkipIfExisting
  285.     chkSkipIfNotExisting.Value = xZip.SkipIfNotExisting
  286.     chkSkipIfOlderDate.Value = xZip.SkipIfOlderDate
  287.     chkSkipIfOlderVersion.Value = xZip.SkipIfOlderVersion
  288. End Sub
  289. '------------------------------------------------------------------------------------
  290. 'Sets the form's controls related to splitting from the xZip objects
  291. '------------------------------------------------------------------------------------
  292. Private Sub LoadSplitFileProperties(xZip As XceedZip)
  293.     txtSplitSize.Text = xZip.SplitSize
  294. End Sub
  295. '------------------------------------------------------------------------------------
  296. ' Shows the frmZip form to the user in order to allow files to be selected
  297. ' for zipping or updating in the zip file.
  298. '------------------------------------------------------------------------------------
  299. Public Function ShowForm(xZip As XceedZip) As Boolean
  300.     ' We keep a link on the xZip, for other forms we could open
  301.     Set xCurrentZip = xZip
  302.      ' Reset the tag to 0, because it is used later to determine if
  303.      ' the frmZip form was closed with instructions to start zipping
  304.     frmZip.Tag = "0"
  305.     ' Set the frmZip form's controls from xZip's property values
  306.     Call LoadProperties(xZip)
  307.     ' Show the frmZip form
  308.     frmZip.Show vbModal
  309.     ' If tag = "1" then the user clicked on the Zip! button located
  310.     ' on the frmZip form. That form has taken care of setting the xZip
  311.     ' objects property values, so we can then immediately start zipping
  312.     ' by calling the sample application's UpdateZipFile sub.
  313.     If frmZip.Tag = "1" Then
  314.         Call UpdateZipFile(xZip)
  315.     End If
  316.     ' If tag = "1" then the user clicked on Zip! and this function returns TRUE
  317.     ShowForm = (frmZip.Tag = "1")
  318. End Function
  319. '------------------------------------------------------------------------------------
  320. 'Sets the FilesToProcess property based on the info entered on the form
  321. '------------------------------------------------------------------------------------
  322. Private Sub UpdateFileProperties(xZip As XceedZip)
  323.     xZip.FilesToProcess = txtFilesToProcess.Text
  324. End Sub
  325. '------------------------------------------------------------------------------------
  326. 'Sets the PreservePaths and ProcessSubfolders properties based on the
  327. 'info entered on the form.
  328. '------------------------------------------------------------------------------------
  329. Private Sub UpdateFolderProperties(xZip As XceedZip)
  330.     xZip.PreservePaths = chkPreservePaths.Value
  331.     xZip.ProcessSubfolders = chkProcessSubFolders.Value
  332. End Sub
  333. '------------------------------------------------------------------------------------
  334. 'Sets the SkipIf* group of properties based on the info entered on the form.
  335. '------------------------------------------------------------------------------------
  336. Private Sub UpdateSkippingProperties(xZip As XceedZip)
  337.     xZip.SkipIfExisting = chkSkipIfExisting.Value
  338.     xZip.SkipIfNotExisting = chkSkipIfNotExisting.Value
  339.     xZip.SkipIfOlderDate = chkSkipIfOlderDate.Value
  340.     xZip.SkipIfOlderVersion = chkSkipIfOlderVersion.Value
  341. End Sub
  342. '------------------------------------------------------------------------------------
  343. 'Sets the SplitSize property based on the info entered on the form.
  344. '------------------------------------------------------------------------------------
  345. Private Sub UpdateSplitFileProperties(xZip As XceedZip)
  346.     If chkSplitting.Value = 1 Then
  347.         xZip.SplitSize = txtSplitSize
  348.     Else
  349.         xZip.SplitSize = 0 ' 0 means that the zip file will not be split.
  350.     End If
  351. End Sub
  352. '------------------------------------------------------------------------------------
  353. 'Calls functions that update xZip's properties based on information
  354. 'found on the form. This is called when the Zip! button is pressed
  355. 'on the frmZip form.
  356. '------------------------------------------------------------------------------------
  357. Private Sub UpdateZipFile(xZip As XceedZip)
  358.     Call UpdateFileProperties(xZip)
  359.     Call UpdateFolderProperties(xZip)
  360.     xZip.CompressionLevel = cmbCompLevel.ItemData(cmbCompLevel.ListIndex)
  361.     Call UpdateSkippingProperties(xZip)
  362.     Call UpdateSplitFileProperties(xZip)
  363. End Sub
  364. '------------------------------------------------------------------------------------
  365. 'Updates the forms controls if you have selected to create a split zip file.
  366. '------------------------------------------------------------------------------------
  367. Private Sub chkSplitting_Click()
  368.     lblSplitSize.Enabled = (chkSplitting.Value = 1)
  369.     lblK.Enabled = (chkSplitting.Value = 1)
  370.     txtSplitSize.Enabled = (chkSplitting.Value = 1)
  371. End Sub
  372. '------------------------------------------------------------------------------------
  373. ' If Zip! is clicked, tag takes the "1" value
  374. '------------------------------------------------------------------------------------
  375. Private Sub cmdZip_Click()
  376.     Tag = "1"
  377.     Hide
  378. End Sub
  379. '------------------------------------------------------------------------------------
  380. ' If cancel is pressed, tag stays at "0"
  381. '------------------------------------------------------------------------------------
  382. Private Sub cmdCancel_Click()
  383.     Hide
  384. End Sub
  385. '------------------------------------------------------------------------------------
  386. ' If the browse button is pressed, a dialog box allowing the user to
  387. ' select files to process will appear. The selected files will then
  388. ' be placed in the edit box where the user can see them and edit them.
  389. '------------------------------------------------------------------------------------
  390. Private Sub cmdFilesToProcess_Click()
  391.     Dim Files As String
  392.     Files = SelectZipFile$(ChooseFiles) ' Open a dialog to select the files
  393.     If Len(Files) > 0 Then
  394.         txtFilesToProcess = txtFilesToProcess + IdentifyFiles(Files)
  395.     End If
  396. End Sub
  397. '------------------------------------------------------------------------------------
  398. 'Opens up the frmFilters window to allow the user to filter files
  399. 'being processed based on various criteria like size, dates and file attributes.
  400. '------------------------------------------------------------------------------------
  401. Private Sub cmdFilters_Click()
  402.     Call frmFilters.ShowForm(xCurrentZip)
  403.     Call Unload(frmFilters)
  404. End Sub
  405. '------------------------------------------------------------------------------------
  406. 'Opens up the frmPassword window to allow the user to specify an encryption password
  407. '------------------------------------------------------------------------------------
  408. Private Sub cmdPasswordProtect_Click()
  409.     Call frmPassword.ShowForm(xCurrentZip)
  410.     Call Unload(frmPassword)
  411. End Sub
  412. '------------------------------------------------------------------------------------
  413. 'Opens up the frmSfx window to allow the user to configure
  414. 'their self-extracting zip files.
  415. '------------------------------------------------------------------------------------
  416. Private Sub cmdSfx_Click()
  417.     Call frmSfx.ShowForm(xCurrentZip)
  418.     Call Unload(frmSfx)
  419. End Sub
  420. '------------------------------------------------------------------------------------
  421. 'Forces the user to enter numerical characters in the SplitSize
  422. 'textbox.
  423. '------------------------------------------------------------------------------------
  424. Private Sub txtSplitSize_KeyPress(KeyAscii As Integer)
  425.     KeyAscii = ValidateNumbers(KeyAscii)
  426. End Sub
  427.